﻿
#region Comment

/*
 * Project：    SpaceLibrary
 * 
 * FileName:    Option/yAxis.cs
 * CreatedOn:   2016-06-23
 * CreatedBy:   农夫有田
 * 
 * 
 * Description：
 *      ->      ECharts3全局参数
 *   
 * History：
 *      ->
 * 
 * Examples：
 *      ->      
 *          
 */

#endregion

namespace SpaceLibrary
{
    using System;
    using System.Collections.Generic;

    #region 全局参数

    /// <summary>
    /// 全局参数
    /// </summary>
    public partial class ECharts3
    {
        #region yAxis

        /// <summary>
        /// 直角坐标系 grid 中的 y 轴，单个 grid 组件最多只能放左右两个 y 轴。
        /// </summary>
        public List<_yAxis> yAxis = new List<_yAxis>();

        public class _yAxis
        {
            #region gridIndex

            private int _gridIndex = 0;

            /// <summary>
            /// y 轴所在的 grid 的索引，默认位于第一个 grid。
            /// <para>[ default: 0 ]</para>
            /// </summary>
            public int gridIndex
            {
                get { return _gridIndex; }
                set { _gridIndex = value; }
            }

            #endregion

            #region position

            private dynamic _position = Params.position.left;

            /// <summary>
            /// y 轴的位置。
            /// <para>[ default: 'left' ]</para>
            /// </summary>
            public dynamic position
            {
                get { return _position; }
                set
                {
                    Type gettype = value.GetType();
                    if (gettype.IsEnum)
                    {
                        switch ((Enum.position)value)
                        {
                            case Enum.position.bottom:
                                _position = Params.position.bottom;
                                break;
                            case Enum.position.top:
                                _position = Params.position.top;
                                break;
                            default:
                                _position = Params.position.bottom;
                                break;
                        }
                    }
                    else
                        _position = value;
                }
            }

            #endregion

            #region type

            private dynamic _type = Params.AxisType.value;

            /// <summary>
            /// 坐标轴类型。
            /// <para>[ default: 'value' ]</para>
            /// </summary>
            public dynamic type
            {
                get { return _type; }
                set
                {
                    Type gettype = value.GetType();
                    if (gettype.IsEnum)
                    {
                        switch ((Enum.AxisType)value)
                        {
                            case Enum.AxisType.value:
                                _type = Params.AxisType.value;
                                break;
                            case Enum.AxisType.category:
                                _type = Params.AxisType.category;
                                break;
                            case Enum.AxisType.time:
                                _type = Params.AxisType.time;
                                break;
                            case Enum.AxisType.log:
                                _type = Params.AxisType.log;
                                break;
                            default:
                                _type = Params.AxisType.value;
                                break;
                        }
                    }
                    else
                        _type = value;
                }
            }

            #endregion

            #region name

            private string _name = string.Empty;

            /// <summary>
            /// 坐标轴名称。
            /// </summary>
            public string name
            {
                get { return _name; }
                set { _name = value; }
            }

            #endregion

            #region nameGap

            public const int _nameGapDefault = 15;

            private int _nameGap = _nameGapDefault;

            /// <summary>
            /// 坐标轴名称与轴线之间的距离。
            /// </summary>
            public int nameGap
            {
                get { return _nameGap; }
                set { _nameGap = value; }
            }

            #endregion

            #region boundaryGap

            private bool _boundaryGap = true;

            /// <summary>
            /// 坐标轴两边留白策略，类目轴和非类目轴的设置和表现不一样。
            /// <para>类目轴中 boundaryGap 可以配置为 true 和 false。默认为 true，这时候刻度只是作为分隔线，标签和数据点都会在两个刻度之间的带(band)中间。</para>
            /// <para>非类目轴，包括时间，数值，对数轴，boundaryGap是一个两个值的数组，分别表示数据最小值和最大值的延伸范围，可以直接设置数值或者相对的百分比，在设置 min 和 max 后无效。</para>
            /// <para>示例：boundaryGap: ['20%', '20%']</para>
            /// </summary>
            public bool boundaryGap
            {
                get { return _boundaryGap; }
                set { _boundaryGap = value; }
            }

            #endregion

            #region data

            private List<dataList> _datalist = new List<dataList>() { };

            /// <summary>
            /// 类目数据，在类目轴（type: 'category'）中有效。
            /// </summary>
            public List<string> data
            {
                get
                {
                    List<string> _data = new List<string> { };
                    foreach (dataList d in _datalist)
                    {
                        _data.Add(d.value);
                    }
                    return _data;
                }
                set
                {
                    foreach (string d in value)
                    {
                        _datalist.Add(new dataList { value = d });
                    }
                }
            }

            /// <summary>
            /// 类目数据，在类目轴（type: 'category'）中有效。
            /// </summary>
            public List<dataList> datalist
            {
                get { return _datalist; }
                set { _datalist = value; }
            }

            #region dataList

            /// <summary>
            /// dataList
            /// </summary>
            public class dataList
            {
                #region value

                private string _value = string.Empty;

                /// <summary>
                /// 单个类目名称
                /// </summary>
                public string value
                {
                    get { return _value; }
                    set { _value = value; }
                }

                #endregion

                #region textStyle

                /// <summary>
                /// 类目标签的文字样式。
                /// </summary>
                public _textStyle textStyle = new _textStyle();

                public class _textStyle
                {
                    #region color

                    private string _color = string.Empty;

                    /// <summary>
                    /// 文字的颜色
                    /// <para>[ default: "#fff" ]</para>
                    /// </summary>
                    public string color
                    {
                        get { return _color; }
                        set { _color = value; }
                    }

                    #endregion

                    #region  left

                    private dynamic _left = Params.align.auto;

                    /// <summary>
                    /// 文字水平对齐方式，默认自动。
                    /// <para>[ default: 'auto' ]</para>
                    /// </summary>
                    public dynamic left
                    {
                        get { return _left; }
                        set
                        {
                            Type type = value.GetType();
                            if (type.IsEnum)
                            {
                                switch ((Enum.align)value)
                                {
                                    case Enum.align.auto:
                                        _left = Params.align.auto;
                                        break;
                                    case Enum.align.left:
                                        _left = Params.align.left;
                                        break;
                                    case Enum.align.center:
                                        _left = Params.align.center;
                                        break;
                                    case Enum.align.right:
                                        _left = Params.align.right;
                                        break;
                                    default:
                                        _left = Params.align.auto;
                                        break;
                                }
                            }
                            else
                                _left = value;

                        }
                    }

                    #endregion

                    #region fontStyle

                    private dynamic _fontStyle = Params.fontStyle.normal;

                    /// <summary>
                    /// 文字字体的粗细
                    /// <para>[ default: 'normal' ]</para>
                    /// </summary>
                    public dynamic fontStyle
                    {
                        get { return _fontStyle; }
                        set
                        {
                            Type type = value.GetType();
                            if (type.IsEnum)
                            {
                                switch ((Enum.fontStyle)value)
                                {
                                    case Enum.fontStyle.normal:
                                        _fontStyle = Params.fontStyle.normal;
                                        break;
                                    case Enum.fontStyle.italic:
                                        _fontStyle = Params.fontStyle.italic;
                                        break;
                                    case Enum.fontStyle.oblique:
                                        _fontStyle = Params.fontStyle.oblique;
                                        break;
                                    default:
                                        _fontStyle = Params.fontStyle.normal;
                                        break;
                                }
                            }
                            else
                                _fontStyle = value;

                        }
                    }

                    #endregion

                    #region fontWeight

                    private dynamic _fontWeight = Params.fontWeight.normal;

                    /// <summary>
                    /// 文字字体的粗细
                    /// <para>[ default: 'normal' ]</para>
                    /// </summary>
                    public dynamic fontWeight
                    {
                        get { return _fontWeight; }
                        set
                        {
                            Type type = value.GetType();
                            if (type.IsEnum)
                            {
                                switch ((Enum.fontWeight)value)
                                {
                                    case Enum.fontWeight.normal:
                                        _fontWeight = Params.fontWeight.normal;
                                        break;
                                    case Enum.fontWeight.bold:
                                        _fontWeight = Params.fontWeight.bold;
                                        break;
                                    case Enum.fontWeight.bolder:
                                        _fontWeight = Params.fontWeight.bolder;
                                        break;
                                    case Enum.fontWeight.lighter:
                                        _fontWeight = Params.fontWeight.lighter;
                                        break;
                                    default:
                                        _fontWeight = Params.fontWeight.normal;
                                        break;
                                }
                            }
                            else
                                _fontWeight = value;

                        }
                    }

                    #endregion

                    #region fontFamily

                    public const string _fontFamilyDefault = "sans-serif";

                    private string _fontFamily = _fontFamilyDefault;

                    /// <summary>
                    /// 文字的字体系列
                    /// <para>[ default: 'sans-serif' ]</para>
                    /// </summary>
                    public string fontFamily
                    {
                        get { return _fontFamily; }
                        set { _fontFamily = value; }
                    }

                    #endregion

                    #region fontSize

                    public const int _fontSizeDefault = 12;

                    private int _fontSize = _fontSizeDefault;

                    /// <summary>
                    /// 文字的字体大小
                    /// <para>[ default: 12 ]</para>
                    /// </summary>
                    public int fontSize
                    {
                        get { return _fontSize; }
                        set { _fontSize = value; }
                    }

                    #endregion

                }

                #endregion

            }

            #endregion

            #endregion
        }

        #endregion
    }

    #endregion
}
